namespace ContractAssertion
{
	using System;
	using System.Collections.Generic;
	using Microsoft.VisualStudio.TestTools.UnitTesting;
	using DependencyLib;
	using CrossFlow.GraphLib;

	[TestClass]
	public class Composition
	{
		DirectedGraph TheGraph;

		[TestInitialize]
		public void Setup()
		{
			IDependencyProvider provider = new MockDependencyProvider("top");
			MockDependencyProvider depends = new MockDependencyProvider("subdigraph0");
			depends.VertexNames.Add("v0");
			depends.VertexNames.Add("v1");
			depends.VertexNames.Add("v2");
			depends.EdgePairs.Add(new KeyValuePair<string, string>("v0", "v1"));
			depends.EdgePairs.Add(new KeyValuePair<string, string>("v0", "v2"));
			depends.EdgePairs.Add(new KeyValuePair<string, string>("v1", "v2"));
			depends.EdgePairs.Add(new KeyValuePair<string, string>("v2", "v1"));
			depends.EdgeNodes.Add(new MockDependencyProvider.EdgeInfo("e", "v1", "v0", 123));
			
			MockDependencyProvider topdepends = provider as MockDependencyProvider;
			topdepends.Subdigraphs.Add(depends.GetDigraphInfoFromCurrentDependencyProvider());
			topdepends.VertexNames.Add("vx");
			topdepends.EdgePairs.Add(new KeyValuePair<string, string>("vx", "subdigraph0"));
			TheGraph = provider.CreateGraph();
		}

		[TestMethod]
		public void SubDigraph()
		{
			Assert.AreEqual<int>(2, TheGraph.VertexCount);
			Assert.AreEqual<int>(3, TheGraph.NodeCount);
			Vertex v = TheGraph.InitialVertex["subdigraph0"];
			Assert.IsNotNull(v);
			Assert.IsTrue(v.IsComposite);
			SubDigraph sub = v as SubDigraph;
			Assert.IsNotNull(sub);
			Assert.AreEqual<int>(3, sub.InnerDigraph.VertexCount);
			Assert.AreEqual<int>(8, sub.InnerDigraph.NodeCount);
		}
	}
}
